/**********************************************************************************************/
/* FBL_ArraySetIterator.h																	  */
/*                                                                       					  */
/* Copyright Paradigma, 1993-2006                                       					  */
/* All Rights Reserved.                                                 					  */
/**********************************************************************************************/

#ifndef _FBL_ArrayIterator_h
   #define _FBL_ArrayIterator_h
#pragma once

#include <VShared/FBL/publ/Sets/FBL_SetIterator.h>
#include <VShared/FBL/publ/Sets/FBL_ArraySet.h>
#include <VShared/FBL/publ/Headers/FBL_pre_header.h>


/**********************************************************************************************/
FBL_Begin_Namespace


/**********************************************************************************************/
SMART_CLASS( ArraySetIterator );


/**********************************************************************************************/
class FBL_SHARED_EXP_CLASS ArraySetIterator : public SetIterator
{
	public://///////////////////////////////////////////////////////////////////////////////////

								ArraySetIterator( void );
								ArraySetIterator( const ArraySet& inSet );

virtual							~ArraySetIterator( void );							

	// -------------------------
	// Properties:

		ulong					get_ColumnCount( void ) const throw() 
									{ return mColumnCount; } 
									
		void					put_ColumnCount( ulong inColumns ) throw() 
									{ mColumnCount = inColumns; } 


	// -------------------------
	// Value methods:

virtual ID_TYPE	 				operator* ( void ) const { return *pCurrentItem; }
								
								/**	Reads contiguously the row of values from the current 
									position with length mColumnCount. */
virtual void 					ReadRow( ID_TYPE* outRow ) const;


	// -------------------------
	// Navigation:

virtual bool					First( void );
virtual bool					Last( void );
 	
virtual bool					Next( void );	
virtual bool					Prev( void );	

virtual bool					GoTo( ulong inIndex );
		
		
	// -------------------------
	// High level methods:

virtual ID_TYPE					FirstItem( void ) 
									{ return ArraySetIterator::First() ? *pCurrentItem : 0; }
								
virtual ID_TYPE					LastItem( void )
									{ return ArraySetIterator::Last() ? *pCurrentItem : 0; }
							
virtual ID_TYPE					NextItem( void )
									{ return ArraySetIterator::Next() ? *pCurrentItem : 0; }
								
virtual ID_TYPE					PrevItem( void )
									{ return ArraySetIterator::Prev() ? *pCurrentItem : 0; }

							
    protected://////////////////////////////////////////////////////////////////////////////////

		Const_ArraySet_Ptr		mpSet;
		ID_TYPE*				pCurrentItem;
		
		ulong 					mColumnCount; 	///< On default = 1. 
												///< For n-dimensional array can be n, to step by records.
};


/**********************************************************************************************/
FBL_End_Namespace

#include <VShared/FBL/publ/Headers/FBL_post_header.h>

#endif // _FBL_ArrayIterator_h
